home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_352 / mg / rexx / notabs.mg < prev    next >
Text File  |  1992-05-06  |  838b  |  46 lines

  1. /* Convert all TABs in a region to spaces */
  2.  
  3. options results
  4.  
  5. 'rexx-region' fooey
  6. 'kill-region'
  7.  
  8. do i=1 to fooey.0
  9.     if index(fooey.i,'0d'x) then text=slashquote(rot13(left(fooey.i,length(fooey.i)-1)))||'\n'
  10.     else text=slashquote(notab(fooey.i))
  11.     'rexx-insert "'||text||'"'
  12.     end
  13. exit
  14.  
  15. notab:procedure
  16. parse arg line
  17. tmp=1
  18. do until tmp=0
  19.     tmp=index(line,'09'x)
  20.     if tmp>0 then do
  21.         no=9-(tmp//8)
  22.         line=delstr(line,tmp,1)
  23.         line=insert(left("",no),line,tmp-1)
  24.         end
  25.     end
  26. return line
  27.  
  28. /* slashquote - puts '\' in front of any '"''s or '\''s we find in a string */
  29. slashquote: procedure
  30. parse arg in
  31.  
  32. i = index(in, '\')
  33. do while i > 0
  34.     in = substr(in, 1, i - 1)'\\'substr(in, i + 1)
  35.     i = index(in, '\', i + 2)
  36.     end
  37.  
  38. i = index(in, '"')
  39. do while i > 0
  40.     in = substr(in, 1, i - 1)'\"'substr(in, i + 1)
  41.     i = index(in, '"', i + 2)
  42.     end
  43.  
  44. return in
  45.  
  46.